package com.hjc.test;

import com.hjc.entity.User;
import com.hjc.service.UserService;

import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class HelloSpringTest2 {

    @Test
        public  void  test1(){
            //通过ClassPathXmlApplicationContext实例化Spring的上下文
            ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");
            UserService service = (UserService)ctx.getBean("service");
            User user = new User();
            user.setId(1);
            user.setUserName("test");
            user.setUserPassword("123456");
            user.setEmail("test@xxx.com");

            service.addNewUser(user);
        }
}
